package com.project.imageinterference.vo;

import org.springframework.http.HttpStatus;

/**
 * ｛ResultCode｝
 *
 * @author x
 */
public enum ResultCode {

    /**
     * 异常声明
     */
    SUCCESS(HttpStatus.OK, 200, "成功"),
    BAD_REQUEST(HttpStatus.BAD_REQUEST, 400, "Bad Request"),
    UNAUTHORIZED(HttpStatus.UNAUTHORIZED, 401, "未登录"),
    FORBIDDEN(HttpStatus.FORBIDDEN, 403, "未授权"),
    PROXY_AUTHENTICATION_REQUIRED(HttpStatus.PROXY_AUTHENTICATION_REQUIRED, 407, "Proxy Authentication Required"),
    INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "服务器异常，请联系管理员"),


    /**
     * 参数异常
     */
    PARAM_IS_INVALID(1001, "参数无效"),
    PARAM_IS_BLANK(1002, "参数为空"),
    PARAM_TYPE_BIND_ERROR(1003, "参数类型错误"),
    BAD_PARAMETER(1004, "请求参数不正确"),


    /**
     * 用户异常
     */
    USER_NOT_LOGGED_IN(2001, "用户未登录，需要验证，请登录"),
    USER_LOGIN_ERROR(2002, "账号不存在或密码错误"),
    USER_NOT_EXIST(2003, "账户不存在"),
    USER_HAS_EXISTED(2004, "用户已存在"),

    IO_IS_INVALID(3001, "IO异常，请检查文件或目录是否存在"),

    NULL_IS_INVALID(4001, "空指针异常，请检查数据是否存在"),

    CLASS_IS_INVALID(5001, "类转换异常，请检查数据对象是否存在"),

    HTTP_IS_INVALID(6001, "HTTP请求异常，请检查请求是否有效"),


    /**
     * HTTP 请求参数
     */
    HTTP_REQUEST_ERROR(10009, "Http 请求异常"),

    /**
     * 数据异常
     */
    DATA_NOT_EXIST(10002, "数据不存在"),
    DATA_EXIST(10003, "数据已经存在"),
    DATA_NOT_EXIST_OR_UNAUTH(10004, "数据不存在或者未授权"),
    DATA_CONVERT_JSON_ERROR(10005, "数据转换为JSON异常"),
    DATA_TYPE_UNMATCH(10006, "数据类型不匹配"),
    DTAT_REPETITION(10007, "数据集出现重复元素"),

    /**
     * 业务异常
     */
    BIZ_STATE_UNMATCH(20001, "状态不正确"),
    BIZ_DATA_DELED(20011, "数据已经删除"),
    REPEAT_PARAMETER(20002, "重复参数"),
    LACK_REQUEST(20003, "请求参数缺失"),
    UNKNOWN(99999, "未知错误"),

    /**
     * 路径异常
     */
    SMB_URL_INVALID(30001, "Samba 路径不合法"),
    SMB_URL_LEN_INVALID(30001, "Samba 路径长度不合法"),
    SMB_URL_CONTAINS(30002, "Samba 路径已经包含"),

    /**
     * 模型相关异常
     */
    MODEL_URL_INVALID(40001, "请检查模型服务调度服务,可能服务已被占用"),


    /**
     * 训练相关异常
     */
    MODEL_VALIDATION_EXCEPTION(50001, "训练结果文件result_validation.txt暂未找到"),
    MODEL_STATICS_EXCEPTION(50002, "读取解析结果异常"),
    MODEL_ZIP_EXCEPTION(50003, "模型压缩失败"),


    PRETREATMENT_NOT_DELETE(60001, "不能删除内置算法"),
    PRETREATMENT_DEFAULT_DELETE(60002, "不能删除默认算法"),


    TRAIN_NOT_DELETE(70001, "训练中的任务都不能进行重新模型训练"),
    TRAIN_BATCH_DELETE(70002, "批量训练模型训练任务 ID 为空"),
    TRAIN_ID_DELETE(70003, "可删除的任务 ID 为空"),
    TRAIN_TASK_INVALID(70004, "识别任务 ID 为空或者识别任务 ID 不合法"),
    TRAIN_DOWN_INVALID(70005, "需要勾选下载选项！"),
    TRAIN_ID_INVALID(70006, "ID 为空或者任务 ID 不合法！"),
    TRAIN_MODEL_INVALID(70007, "未找到有效的模型数据"),


    ;

    /**
     * 返回HTTP状态码，符合http请求
     */
    private final HttpStatus httpStatus;

    /**
     * 业务异常码
     */
    private final Integer code;

    /**
     * 业务异常信息描述
     */
    private final String message;

    /**
     * 有参构造函数
     */
    ResultCode(HttpStatus httpStatus, Integer code, String message) {
        this.httpStatus = httpStatus;
        this.code = code;
        this.message = message;
    }

    /**
     * 有参构造函数
     */
    ResultCode(Integer code, String message) {
        this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
        this.code = code;
        this.message = message;
    }

    /**
     * @return the httpStatus
     */
    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
